Discovering Assembly
To follow this guide, you will need to navigate to the guides/discovering-assembly/support
directory.
Open the
ex1.asm
file and read the comments. Assemble it by using themake
utility and run it. Using gdb, go through the program line by line (thestart
command followed bynext
) and observe the changes in register values after executing themov
andadd
instructions. Ignore the sequence ofPRINTF32
instructions.Open the
ex2.asm
file and read the comments. Assemble it by using themake
utility and run it. Using gdb, observe the change in theeip
register when executing thejmp
instruction. To skip thePRINTF32
instructions, add a breakpoint at thejump_incoming
label (thebreak
command followed byrun
).Open the
ex3.asm
file and read the comments. Assemble it by using themake
utility and run it. Using gdb, navigate through the program using breakpoints. Follow the program flow. Why is15
displayed first and then3
? Because of the jump at line 9. Where does the jump at line 25 point to? To thezone1
label.Open the
ex4.asm
file and read the comments. Assemble it by using themake
utility and run it. Using gdb, go through the program. Why isn't the jump at line 12 taken? Because theje
instruction jumps if theZF
bit in theFLAGS
register is set. This bit is set by thecmp
instruction, which calculates the difference between the values of theeax
andebx
registers without storing the result. However, theadd
instruction at line 11 clears this flag because the result of the operation is different from 0.